home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_xemacs.idb / usr / freeware / lib / xemacs-20.4 / lisp / iso / iso-cvt.el.z / iso-cvt.el
Encoding:
Text File  |  1998-05-21  |  17.2 KB  |  720 lines

  1. ;;; iso-cvt.el --- translate to ISO 8859-1 from/to net/TeX conventions
  2. ;; This file was formerly called gm-lingo.el.
  3.  
  4. ;; Copyright (C) 1993, 1994 Free Software Foundation, Inc.
  5.  
  6. ;; Author: Michael Gschwind <mike@vlsivie.tuwien.ac.at>
  7. ;; Keywords: tex, iso, latin, i18n
  8.  
  9. ;; This file is part of XEmacs.
  10.  
  11. ;; XEmacs is free software; you can redistribute it and/or modify
  12. ;; it under the terms of the GNU General Public License as published by
  13. ;; the Free Software Foundation; either version 2, or (at your option)
  14. ;; any later version.
  15.  
  16. ;; XEmacs is distributed in the hope that it will be useful,
  17. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19. ;; GNU General Public License for more details.
  20.  
  21. ;; You should have received a copy of the GNU General Public License
  22. ;; along with XEmacs; see the file COPYING.  If not, write to the
  23. ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  24. ;; Boston, MA 02111-1307, USA.
  25.  
  26. ;;; Synched up with: FSF 19.34.
  27.  
  28. ;;; Commentary: 
  29.  
  30. ;; This lisp code serves two purposes, both of which involve 
  31. ;; the translation of various conventions for representing European 
  32. ;; character sets to ISO 8859-1.
  33.  
  34. ;; Net support: 
  35. ;; Various conventions exist in Newsgroups on how to represent national 
  36. ;; characters. The functions provided here translate these net conventions 
  37. ;; to ISO.
  38. ;;
  39. ;; Calling `iso-german' will turn the net convention for umlauts ("a etc.) 
  40. ;; into ISO latin1 umlauts for easy reading.
  41. ;; 'iso-spanish' will turn net conventions for representing spanish 
  42. ;; to ISO latin1. (Note that accents are omitted in news posts most 
  43. ;; of the time, only enye is escaped.)
  44.  
  45. ;; TeX support
  46. ;; This mode installs hooks which change TeX files to ISO Latin-1 for 
  47. ;; simplified editing. When the TeX file is saved, ISO latin1 characters are
  48. ;; translated back to escape sequences.
  49. ;;
  50. ;; An alternative is a TeX style that handles 8 bit ISO files 
  51. ;; (available on ftp.vlsivie.tuwien.ac.at in /pub/8bit)  
  52. ;; - but these files are difficult to transmit ... so while the net is  
  53. ;; still @ 7 bit this may be useful
  54.  
  55. ;;; TO DO:
  56. ;; The net support should install hooks (like TeX support does) 
  57. ;; which recognizes certain news groups and translates all articles from 
  58. ;; those groups. 
  59. ;;
  60. ;; Cover more cases for translation (There is an infinite number of ways to 
  61. ;; represent accented characters in TeX)
  62.  
  63. ;;; SEE ALSO:
  64. ;; If you are interested in questions related to using the ISO 8859-1 
  65. ;; characters set (configuring emacs, Unix, etc. to use ISO), then you
  66. ;; can get the ISO 8859-1 FAQ via anonymous ftp from 
  67. ;; ftp.vlsivie.tuwien.ac.at in /pub/bit/FAQ-ISO-8859-1
  68.  
  69. ;;; Code:
  70.  
  71. (provide 'iso-cvt)
  72.  
  73. (defvar iso-spanish-trans-tab
  74.   '(
  75.     ("~n" "±")
  76.     ("\([a-zA-Z]\)#" "\\1±")
  77.     ("~N" "╤")
  78.     ("\\([-a-zA-Z\"`]\\)\"u" "\\1ⁿ")
  79.     ("\\([-a-zA-Z\"`]\\)\"U" "\\1▄")
  80.     ("\\([-a-zA-Z]\\)'o" "\\1≤")
  81.     ("\\([-a-zA-Z]\\)'O" "\\╙")
  82.     ("\\([-a-zA-Z]\\)'e" "\\1Θ")
  83.     ("\\([-a-zA-Z]\\)'E" "\\1╔")
  84.     ("\\([-a-zA-Z]\\)'a" "\\1ß")
  85.     ("\\([-a-zA-Z]\\)'A" "\\1A")
  86.     ("\\([-a-zA-Z]\\)'i" "\\1φ")
  87.     ("\\([-a-zA-Z]\\)'I" "\\1═")
  88.     )
  89.   "Spanish translation table.")
  90.  
  91. (defun iso-translate-conventions (trans-tab)
  92.   "Use the translation table TRANS-TAB to translate the current buffer."
  93.   (save-excursion
  94.     (goto-char (point-min))
  95.     (let ((work-tab trans-tab)
  96.       (buffer-read-only nil)
  97.       (case-fold-search nil))
  98.       (while work-tab
  99.     (save-excursion
  100.       (let ((trans-this (car work-tab)))
  101.         (while (re-search-forward (car trans-this) nil t)
  102.           (replace-match (car (cdr trans-this)) t nil)))
  103.       (setq work-tab (cdr work-tab)))))))
  104.  
  105. (defun iso-spanish ()
  106.   "Translate net conventions for Spanish to ISO 8859-1."
  107.   (interactive)
  108.   (iso-translate-conventions iso-spanish-trans-tab))
  109.  
  110. (defvar iso-aggressive-german-trans-tab
  111.   '(
  112.     ("\"a" "Σ")
  113.     ("\"A" "─")
  114.     ("\"o" "÷")
  115.     ("\"O" "╓")
  116.     ("\"u" "ⁿ")
  117.     ("\"U" "▄")
  118.     ("\"s" "▀")
  119.     ("\\\\3" "▀")
  120.     )
  121.   "German translation table. 
  122. This table uses an aggressive translation approach and may erroneously
  123. translate too much.")
  124.  
  125. (defvar iso-conservative-german-trans-tab
  126.   '(
  127.     ("\\([-a-zA-Z\"`]\\)\"a" "\\1Σ")
  128.     ("\\([-a-zA-Z\"`]\\)\"A" "\\1─")
  129.     ("\\([-a-zA-Z\"`]\\)\"o" "\\1÷")
  130.     ("\\([-a-zA-Z\"`]\\)\"O" "\\1╓")
  131.     ("\\([-a-zA-Z\"`]\\)\"u" "\\1ⁿ")
  132.     ("\\([-a-zA-Z\"`]\\)\"U" "\\1▄")
  133.     ("\\([-a-zA-Z\"`]\\)\"s" "\\1▀")
  134.     ("\\([-a-zA-Z\"`]\\)\\\\3" "\\1▀")
  135.     )
  136.   "German translation table.
  137. This table uses a conservative translation approach and may translate too 
  138. little.")
  139.  
  140.  
  141. (defvar iso-german-trans-tab iso-aggressive-german-trans-tab 
  142.   "Currently active translation table for German.")
  143.  
  144. (defun iso-german ()
  145.  "Translate net conventions for German to ISO 8859-1."
  146.  (interactive)
  147.  (iso-translate-conventions iso-german-trans-tab))
  148.  
  149. (defvar iso-iso2tex-trans-tab
  150.   '(
  151.     ("Σ" "{\\\\\"a}")
  152.     ("α" "{\\\\`a}")
  153.     ("ß" "{\\\\'a}")
  154.     ("π" "{\\\\~a}")
  155.     ("Γ" "{\\\\^a}")
  156.     ("δ" "{\\\\\"e}")
  157.     ("Φ" "{\\\\`e}")
  158.     ("Θ" "{\\\\'e}")
  159.     ("Ω" "{\\\\^e}")
  160.     ("∩" "{\\\\\"\\\\i}")
  161.     ("∞" "{\\\\`\\\\i}")
  162.     ("φ" "{\\\\'\\\\i}")
  163.     ("ε" "{\\\\^\\\\i}")
  164.     ("÷" "{\\\\\"o}")
  165.     ("≥" "{\\\\`o}")
  166.     ("≤" "{\\\\'o}")
  167.     ("⌡" "{\\\\~o}")
  168.     ("⌠" "{\\\\^o}")
  169.     ("ⁿ" "{\\\\\"u}")
  170.     ("∙" "{\\\\`u}")
  171.     ("·" "{\\\\'u}")
  172.     ("√" "{\\\\^u}")
  173.     ("─" "{\\\\\"A}")
  174.     ("└" "{\\\\`A}")
  175.     ("┴" "{\\\\'A}")
  176.     ("├" "{\\\\~A}")
  177.     ("┬" "{\\\\^A}")
  178.     ("╦" "{\\\\\"E}")
  179.     ("╚" "{\\\\`E}")
  180.     ("╔" "{\\\\'E}")
  181.     ("╩" "{\\\\^E}")
  182.     ("╧" "{\\\\\"I}")
  183.     ("╠" "{\\\\`I}")
  184.     ("═" "{\\\\'I}")
  185.     ("╬" "{\\\\^I}")
  186.     ("╓" "{\\\\\"O}")
  187.     ("╥" "{\\\\`O}")
  188.     ("╙" "{\\\\'O}")
  189.     ("╒" "{\\\\~O}")
  190.     ("╘" "{\\\\^O}")
  191.     ("▄" "{\\\\\"U}")
  192.     ("┘" "{\\\\`U}")
  193.     ("┌" "{\\\\'U}")
  194.     ("█" "{\\\\^U}")
  195.     ("±" "{\\\\~n}")
  196.     ("╤" "{\\\\~N}")
  197.     ("τ" "{\\\\c c}")
  198.     ("╟" "{\\\\c C}")
  199.     ("▀" "{\\\\ss}")
  200.     ("\306" "{\\\\AE}")
  201.     ("\346" "{\\\\ae}")
  202.     ("\305" "{\\\\AA}")
  203.     ("\345" "{\\\\aa}")
  204.     ("\251" "{\\\\copyright}")
  205.     ("ú" "{\\\\pounds}")
  206.     ("╢" "{\\\\P}")
  207.     ("º" "{\\\\S}")
  208.     ("┐" "{?`}")
  209.     ("í" "{!`}")
  210.     )
  211.   "Translation table for translating ISO 8859-1 characters to TeX sequences.")
  212.  
  213.  
  214.  
  215.  
  216. (defun iso-iso2tex ()
  217.  "Translate ISO 8859-1 characters to TeX sequences."
  218.  (interactive)
  219.  (iso-translate-conventions iso-iso2tex-trans-tab))
  220.  
  221.  
  222. (defvar iso-tex2iso-trans-tab
  223.   '(
  224.     ("{\\\\\"a}" "Σ")
  225.     ("{\\\\`a}" "α")
  226.     ("{\\\\'a}" "ß")
  227.     ("{\\\\~a}" "π")
  228.     ("{\\\\^a}" "Γ")
  229.     ("{\\\\\"e}" "δ")
  230.     ("{\\\\`e}" "Φ")
  231.     ("{\\\\'e}" "Θ")
  232.     ("{\\\\^e}" "Ω")
  233.     ("{\\\\\"\\\\i}" "∩")
  234.     ("{\\\\`\\\\i}" "∞")
  235.     ("{\\\\'\\\\i}" "φ")
  236.     ("{\\\\^\\\\i}" "ε")
  237.     ("{\\\\\"i}" "∩")
  238.     ("{\\\\`i}" "∞")
  239.     ("{\\\\'i}" "φ")
  240.     ("{\\\\^i}" "ε")
  241.     ("{\\\\\"o}" "÷")
  242.     ("{\\\\`o}" "≥")
  243.     ("{\\\\'o}" "≤")
  244.     ("{\\\\~o}" "⌡")
  245.     ("{\\\\^o}" "⌠")
  246.     ("{\\\\\"u}" "ⁿ")
  247.     ("{\\\\`u}" "∙")
  248.     ("{\\\\'u}" "·")
  249.     ("{\\\\^u}" "√")
  250.     ("{\\\\\"A}" "─")
  251.     ("{\\\\`A}" "└")
  252.     ("{\\\\'A}" "┴")
  253.     ("{\\\\~A}" "├")
  254.     ("{\\\\^A}" "┬")
  255.     ("{\\\\\"E}" "╦")
  256.     ("{\\\\`E}" "╚")
  257.     ("{\\\\'E}" "╔")
  258.     ("{\\\\^E}" "╩")
  259.     ("{\\\\\"I}" "╧")
  260.     ("{\\\\`I}" "╠")
  261.     ("{\\\\'I}" "═")
  262.     ("{\\\\^I}" "╬")
  263.     ("{\\\\\"O}" "╓")
  264.     ("{\\\\`O}" "╥")
  265.     ("{\\\\'O}" "╙")
  266.     ("{\\\\~O}" "╒")
  267.     ("{\\\\^O}" "╘")
  268.     ("{\\\\\"U}" "▄")
  269.     ("{\\\\`U}" "┘")
  270.     ("{\\\\'U}" "┌")
  271.     ("{\\\\^U}" "█")
  272.     ("{\\\\~n}" "±")
  273.     ("{\\\\~N}" "╤")
  274.     ("{\\\\c c}" "τ")
  275.     ("{\\\\c C}" "╟")
  276.     ("\\\\\"a" "Σ")
  277.     ("\\\\`a" "α")
  278.     ("\\\\'a" "ß")
  279.     ("\\\\~a" "π")
  280.     ("\\\\^a" "Γ")
  281.     ("\\\\\"e" "δ")
  282.     ("\\\\`e" "Φ")
  283.     ("\\\\'e" "Θ")
  284.     ("\\\\^e" "Ω")
  285.     ("\\\\\"\\\\i" "∩")
  286.     ("\\\\`\\\\i" "∞")
  287.     ("\\\\'\\\\i" "φ")
  288.     ("\\\\^\\\\i" "ε")
  289.     ("\\\\\"i" "∩")
  290.     ("\\\\`i" "∞")
  291.     ("\\\\'i" "φ")
  292.     ("\\\\^i" "ε")
  293.     ("\\\\\"o" "÷")
  294.     ("\\\\`o" "≥")
  295.     ("\\\\'o" "≤")
  296.     ("\\\\~o" "⌡")
  297.     ("\\\\^o" "⌠")
  298.     ("\\\\\"u" "ⁿ")
  299.     ("\\\\`u" "∙")
  300.     ("\\\\'u" "·")
  301.     ("\\\\^u" "√")
  302.     ("\\\\\"A" "─")
  303.     ("\\\\`A" "└")
  304.     ("\\\\'A" "┴")
  305.     ("\\\\~A" "├")
  306.     ("\\\\^A" "┬")
  307.     ("\\\\\"E" "╦")
  308.     ("\\\\`E" "╚")
  309.     ("\\\\'E" "╔")
  310.     ("\\\\^E" "╩")
  311.     ("\\\\\"I" "╧")
  312.     ("\\\\`I" "╠")
  313.     ("\\\\'I" "═")
  314.     ("\\\\^I" "╬")
  315.     ("\\\\\"O" "╓")
  316.     ("\\\\`O" "╥")
  317.     ("\\\\'O" "╙")
  318.     ("\\\\~O" "╒")
  319.     ("\\\\^O" "╘")
  320.     ("\\\\\"U" "▄")
  321.     ("\\\\`U" "┘")
  322.     ("\\\\'U" "┌")
  323.     ("\\\\^U" "█")
  324.     ("\\\\~n" "±")
  325.     ("\\\\~N" "╤")
  326.     ("\\\\\"{a}" "Σ")
  327.     ("\\\\`{a}" "α")
  328.     ("\\\\'{a}" "ß")
  329.     ("\\\\~{a}" "π")
  330.     ("\\\\^{a}" "Γ")
  331.     ("\\\\\"{e}" "δ")
  332.     ("\\\\`{e}" "Φ")
  333.     ("\\\\'{e}" "Θ")
  334.     ("\\\\^{e}" "Ω")
  335.     ("\\\\\"{\\\\i}" "∩")
  336.     ("\\\\`{\\\\i}" "∞")
  337.     ("\\\\'{\\\\i}" "φ")
  338.     ("\\\\^{\\\\i}" "ε")
  339.     ("\\\\\"{i}" "∩")
  340.     ("\\\\`{i}" "∞")
  341.     ("\\\\'{i}" "φ")
  342.     ("\\\\^{i}" "ε")
  343.     ("\\\\\"{o}" "÷")
  344.     ("\\\\`{o}" "≥")
  345.     ("\\\\'{o}" "≤")
  346.     ("\\\\~{o}" "⌡")
  347.     ("\\\\^{o}" "⌠")
  348.     ("\\\\\"{u}" "ⁿ")
  349.     ("\\\\`{u}" "∙")
  350.     ("\\\\'{u}" "·")
  351.     ("\\\\^{u}" "√")
  352.     ("\\\\\"{A}" "─")
  353.     ("\\\\`{A}" "└")
  354.     ("\\\\'{A}" "┴")
  355.     ("\\\\~{A}" "├")
  356.     ("\\\\^{A}" "┬")
  357.     ("\\\\\"{E}" "╦")
  358.     ("\\\\`{E}" "╚")
  359.     ("\\\\'{E}" "╔")
  360.     ("\\\\^{E}" "╩")
  361.     ("\\\\\"{I}" "╧")
  362.     ("\\\\`{I}" "╠")
  363.     ("\\\\'{I}" "═")
  364.     ("\\\\^{I}" "╬")
  365.     ("\\\\\"{O}" "╓")
  366.     ("\\\\`{O}" "╥")
  367.     ("\\\\'{O}" "╙")
  368.     ("\\\\~{O}" "╒")
  369.     ("\\\\^{O}" "╘")
  370.     ("\\\\\"{U}" "▄")
  371.     ("\\\\`{U}" "┘")
  372.     ("\\\\'{U}" "┌")
  373.     ("\\\\^{U}" "█")
  374.     ("\\\\~{n}" "±")
  375.     ("\\\\~{N}" "╤")
  376.     ("\\\\c{c}" "τ")
  377.     ("\\\\c{C}" "╟")
  378.     ("{\\\\ss}" "▀")
  379.     ("{\\\\AE}" "\306")
  380.     ("{\\\\ae}" "\346")
  381.     ("{\\\\AA}" "\305")
  382.     ("{\\\\aa}" "\345")
  383.     ("{\\\\copyright}" "\251")
  384.     ("\\\\copyright{}" "\251")
  385.     ("{\\\\pounds}" "ú" )
  386.     ("{\\\\P}" "╢" )
  387.     ("{\\\\S}" "º" )
  388.     ("\\\\pounds{}" "ú" )
  389.     ("\\\\P{}" "╢" )
  390.     ("\\\\S{}" "º" )
  391.     ("{\\?`}" "┐")
  392.     ("{!`}" "í")
  393.     ("\\?`" "┐")
  394.     ("!`" "í")
  395.     )
  396.   "Translation table for translating TeX sequences to ISO 8859-1 characters. 
  397. This table is not exhaustive (and due to TeX's power can never be). It only
  398. contains commonly used sequences.")
  399.  
  400. (defun iso-tex2iso ()
  401.  "Translate TeX sequences to ISO 8859-1 characters."
  402.  (interactive)
  403.  (iso-translate-conventions iso-tex2iso-trans-tab))
  404.  
  405. (defvar iso-gtex2iso-trans-tab
  406.   '(
  407.     ("{\\\\\"a}" "Σ")
  408.     ("{\\\\`a}" "α")
  409.     ("{\\\\'a}" "ß")
  410.     ("{\\\\~a}" "π")
  411.     ("{\\\\^a}" "Γ")
  412.     ("{\\\\\"e}" "δ")
  413.     ("{\\\\`e}" "Φ")
  414.     ("{\\\\'e}" "Θ")
  415.     ("{\\\\^e}" "Ω")
  416.     ("{\\\\\"\\\\i}" "∩")
  417.     ("{\\\\`\\\\i}" "∞")
  418.     ("{\\\\'\\\\i}" "φ")
  419.     ("{\\\\^\\\\i}" "ε")
  420.     ("{\\\\\"i}" "∩")
  421.     ("{\\\\`i}" "∞")
  422.     ("{\\\\'i}" "φ")
  423.     ("{\\\\^i}" "ε")
  424.     ("{\\\\\"o}" "÷")
  425.     ("{\\\\`o}" "≥")
  426.     ("{\\\\'o}" "≤")
  427.     ("{\\\\~o}" "⌡")
  428.     ("{\\\\^o}" "⌠")
  429.     ("{\\\\\"u}" "ⁿ")
  430.     ("{\\\\`u}" "∙")
  431.     ("{\\\\'u}" "·")
  432.     ("{\\\\^u}" "√")
  433.     ("{\\\\\"A}" "─")
  434.     ("{\\\\`A}" "└")
  435.     ("{\\\\'A}" "┴")
  436.     ("{\\\\~A}" "├")
  437.     ("{\\\\^A}" "┬")
  438.     ("{\\\\\"E}" "╦")
  439.     ("{\\\\`E}" "╚")
  440.     ("{\\\\'E}" "╔")
  441.     ("{\\\\^E}" "╩")
  442.     ("{\\\\\"I}" "╧")
  443.     ("{\\\\`I}" "╠")
  444.     ("{\\\\'I}" "═")
  445.     ("{\\\\^I}" "╬")
  446.     ("{\\\\\"O}" "╓")
  447.     ("{\\\\`O}" "╥")
  448.     ("{\\\\'O}" "╙")
  449.     ("{\\\\~O}" "╒")
  450.     ("{\\\\^O}" "╘")
  451.     ("{\\\\\"U}" "▄")
  452.     ("{\\\\`U}" "┘")
  453.     ("{\\\\'U}" "┌")
  454.     ("{\\\\^U}" "█")
  455.     ("{\\\\~n}" "±")
  456.     ("{\\\\~N}" "╤")
  457.     ("{\\\\c c}" "τ")
  458.     ("{\\\\c C}" "╟")
  459.     ("\\\\\"a" "Σ")
  460.     ("\\\\`a" "α")
  461.     ("\\\\'a" "ß")
  462.     ("\\\\~a" "π")
  463.     ("\\\\^a" "Γ")
  464.     ("\\\\\"e" "δ")
  465.     ("\\\\`e" "Φ")
  466.     ("\\\\'e" "Θ")
  467.     ("\\\\^e" "Ω")
  468.     ("\\\\\"\\\\i" "∩")
  469.     ("\\\\`\\\\i" "∞")
  470.     ("\\\\'\\\\i" "φ")
  471.     ("\\\\^\\\\i" "ε")
  472.     ("\\\\\"i" "∩")
  473.     ("\\\\`i" "∞")
  474.     ("\\\\'i" "φ")
  475.     ("\\\\^i" "ε")
  476.     ("\\\\\"o" "÷")
  477.     ("\\\\`o" "≥")
  478.     ("\\\\'o" "≤")
  479.     ("\\\\~o" "⌡")
  480.     ("\\\\^o" "⌠")
  481.     ("\\\\\"u" "ⁿ")
  482.     ("\\\\`u" "∙")
  483.     ("\\\\'u" "·")
  484.     ("\\\\^u" "√")
  485.     ("\\\\\"A" "─")
  486.     ("\\\\`A" "└")
  487.     ("\\\\'A" "┴")
  488.     ("\\\\~A" "├")
  489.     ("\\\\^A" "┬")
  490.     ("\\\\\"E" "╦")
  491.     ("\\\\`E" "╚")
  492.     ("\\\\'E" "╔")
  493.     ("\\\\^E" "╩")
  494.     ("\\\\\"I" "╧")
  495.     ("\\\\`I" "╠")
  496.     ("\\\\'I" "═")
  497.     ("\\\\^I" "╬")
  498.     ("\\\\\"O" "╓")
  499.     ("\\\\`O" "╥")
  500.     ("\\\\'O" "╙")
  501.     ("\\\\~O" "╒")
  502.     ("\\\\^O" "╘")
  503.     ("\\\\\"U" "▄")
  504.     ("\\\\`U" "┘")
  505.     ("\\\\'U" "┌")
  506.     ("\\\\^U" "█")
  507.     ("\\\\~n" "±")
  508.     ("\\\\~N" "╤")
  509.     ("\\\\\"{a}" "Σ")
  510.     ("\\\\`{a}" "α")
  511.     ("\\\\'{a}" "ß")
  512.     ("\\\\~{a}" "π")
  513.     ("\\\\^{a}" "Γ")
  514.     ("\\\\\"{e}" "δ")
  515.     ("\\\\`{e}" "Φ")
  516.     ("\\\\'{e}" "Θ")
  517.     ("\\\\^{e}" "Ω")
  518.     ("\\\\\"{\\\\i}" "∩")
  519.     ("\\\\`{\\\\i}" "∞")
  520.     ("\\\\'{\\\\i}" "φ")
  521.     ("\\\\^{\\\\i}" "ε")
  522.     ("\\\\\"{i}" "∩")
  523.     ("\\\\`{i}" "∞")
  524.     ("\\\\'{i}" "φ")
  525.     ("\\\\^{i}" "ε")
  526.     ("\\\\\"{o}" "÷")
  527.     ("\\\\`{o}" "≥")
  528.     ("\\\\'{o}" "≤")
  529.     ("\\\\~{o}" "⌡")
  530.     ("\\\\^{o}" "⌠")
  531.     ("\\\\\"{u}" "ⁿ")
  532.     ("\\\\`{u}" "∙")
  533.     ("\\\\'{u}" "·")
  534.     ("\\\\^{u}" "√")
  535.     ("\\\\\"{A}" "─")
  536.     ("\\\\`{A}" "└")
  537.     ("\\\\'{A}" "┴")
  538.     ("\\\\~{A}" "├")
  539.     ("\\\\^{A}" "┬")
  540.     ("\\\\\"{E}" "╦")
  541.     ("\\\\`{E}" "╚")
  542.     ("\\\\'{E}" "╔")
  543.     ("\\\\^{E}" "╩")
  544.     ("\\\\\"{I}" "╧")
  545.     ("\\\\`{I}" "╠")
  546.     ("\\\\'{I}" "═")
  547.     ("\\\\^{I}" "╬")
  548.     ("\\\\\"{O}" "╓")
  549.     ("\\\\`{O}" "╥")
  550.     ("\\\\'{O}" "╙")
  551.     ("\\\\~{O}" "╒")
  552.     ("\\\\^{O}" "╘")
  553.     ("\\\\\"{U}" "▄")
  554.     ("\\\\`{U}" "┘")
  555.     ("\\\\'{U}" "┌")
  556.     ("\\\\^{U}" "█")
  557.     ("\\\\~{n}" "±")
  558.     ("\\\\~{N}" "╤")
  559.     ("\\\\c{c}" "τ")
  560.     ("\\\\c{C}" "╟")
  561.     ("{\\\\ss}" "▀")
  562.     ("{\\\\AE}" "\306")
  563.     ("{\\\\ae}" "\346")
  564.     ("{\\\\AA}" "\305")
  565.     ("{\\\\aa}" "\345")
  566.     ("{\\\\copyright}" "\251")
  567.     ("\\\\copyright{}" "\251")
  568.     ("{\\\\pounds}" "ú" )
  569.     ("{\\\\P}" "╢" )
  570.     ("{\\\\S}" "º" )
  571.     ("\\\\pounds{}" "ú" )
  572.     ("\\\\P{}" "╢" )
  573.     ("\\\\S{}" "º" )
  574.     ("?`" "┐")
  575.     ("!`" "í")
  576.     ("{?`}" "┐")
  577.     ("{!`}" "í")
  578.     ("\"a" "Σ")
  579.     ("\"A" "─")
  580.     ("\"o" "÷")
  581.     ("\"O" "╓")
  582.     ("\"u" "ⁿ")
  583.     ("\"U" "▄")
  584.     ("\"s" "▀")
  585.     ("\\\\3" "▀")
  586.     )
  587.   "Translation table for translating German TeX sequences to ISO 8859-1.
  588. This table is not exhaustive (and due to TeX's power can never be).  It only
  589. contains commonly used sequences.")
  590.  
  591. (defvar iso-iso2gtex-trans-tab
  592.   '(
  593.     ("Σ" "\"a")
  594.     ("α" "{\\\\`a}")
  595.     ("ß" "{\\\\'a}")
  596.     ("π" "{\\\\~a}")
  597.     ("Γ" "{\\\\^a}")
  598.     ("δ" "{\\\\\"e}")
  599.     ("Φ" "{\\\\`e}")
  600.     ("Θ" "{\\\\'e}")
  601.     ("Ω" "{\\\\^e}")
  602.     ("∩" "{\\\\\"\\\\i}")
  603.     ("∞" "{\\\\`\\\\i}")
  604.     ("φ" "{\\\\'\\\\i}")
  605.     ("ε" "{\\\\^\\\\i}")
  606.     ("÷" "\"o")
  607.     ("≥" "{\\\\`o}")
  608.     ("≤" "{\\\\'o}")
  609.     ("⌡" "{\\\\~o}")
  610.     ("⌠" "{\\\\^o}")
  611.     ("ⁿ" "\"u")
  612.     ("∙" "{\\\\`u}")
  613.     ("·" "{\\\\'u}")
  614.     ("√" "{\\\\^u}")
  615.     ("─" "\"A")
  616.     ("└" "{\\\\`A}")
  617.     ("┴" "{\\\\'A}")
  618.     ("├" "{\\\\~A}")
  619.     ("┬" "{\\\\^A}")
  620.     ("╦" "{\\\\\"E}")
  621.     ("╚" "{\\\\`E}")
  622.     ("╔" "{\\\\'E}")
  623.     ("╩" "{\\\\^E}")
  624.     ("╧" "{\\\\\"I}")
  625.     ("╠" "{\\\\`I}")
  626.     ("═" "{\\\\'I}")
  627.     ("╬" "{\\\\^I}")
  628.     ("╓" "\"O")
  629.     ("╥" "{\\\\`O}")
  630.     ("╙" "{\\\\'O}")
  631.     ("╒" "{\\\\~O}")
  632.     ("╘" "{\\\\^O}")
  633.     ("▄" "\"U")
  634.     ("┘" "{\\\\`U}")
  635.     ("┌" "{\\\\'U}")
  636.     ("█" "{\\\\^U}")
  637.     ("±" "{\\\\~n}")
  638.     ("╤" "{\\\\~N}")
  639.     ("τ" "{\\\\c c}")
  640.     ("╟" "{\\\\c C}")
  641.     ("▀" "\"s")
  642.     ("\306" "{\\\\AE}")
  643.     ("\346" "{\\\\ae}")
  644.     ("\305" "{\\\\AA}")
  645.     ("\345" "{\\\\aa}")
  646.     ("\251" "{\\\\copyright}")
  647.     ("ú" "{\\\\pounds}")
  648.     ("╢" "{\\\\P}")
  649.     ("º" "{\\\\S}")
  650.     ("┐" "{?`}")
  651.     ("í" "{!`}")
  652.     )
  653.   "Translation table for translating ISO 8859-1 characters to German TeX.")
  654.  
  655. (defun iso-gtex2iso ()
  656.  "Translate German TeX sequences to ISO 8859-1 characters."
  657.  (interactive)
  658.  (iso-translate-conventions iso-gtex2iso-trans-tab))
  659.  
  660.  
  661. (defun iso-iso2gtex ()
  662.  "Translate ISO 8859-1 characters to German TeX sequences."
  663.  (interactive)
  664.  (iso-translate-conventions iso-iso2gtex-trans-tab))
  665.  
  666.  
  667. (defun iso-german-tex-p ()
  668.  "Check if tex buffer is German LaTeX."
  669.  (save-excursion
  670.    (save-restriction
  671.      (widen)
  672.      (goto-char (point-min))
  673.      (re-search-forward "\\\\documentstyle\\[.*german.*\\]" nil t))))
  674.  
  675. (defun iso-fix-iso2tex ()
  676.   "Turn ISO 8859-1 (aka. ISO Latin-1) buffer into TeX sequences.
  677. If German TeX is used, German TeX sequences are generated."
  678.   (if (or (equal major-mode 'latex-mode)
  679.       (equal major-mode 'LaTeX-mode)) ; AucTeX wants this
  680.       (if (iso-german-tex-p)
  681.       (iso-iso2gtex)
  682.     (iso-iso2tex)))
  683.   (if (or (equal major-mode 'tex-mode)
  684.       (equal major-mode 'TeX-mode) ; AucTeX wants this
  685.       (equal major-mode 'plain-tex-mode))
  686.       (iso-iso2tex)))
  687.  
  688. (defun iso-fix-tex2iso ()
  689.   "Turn TeX sequences into ISO 8859-1 (aka. ISO Latin-1) characters.
  690. This function recognizes German TeX buffers."
  691.   (if (or (equal major-mode 'latex-mode)
  692.       (equal major-mode 'Latex-mode)) ; AucTeX wants this
  693.       (if (iso-german-tex-p)
  694.       (iso-gtex2iso)
  695.     (iso-tex2iso)))
  696.   (if (or (equal major-mode 'tex-mode)
  697.       (equal major-mode 'TeX-mode)  ; AucTeX wants this
  698.       (equal major-mode 'plain-tex-mode))
  699.       (iso-tex2iso)))
  700.  
  701. (defun iso-cvt-ffh ()
  702.   "find-file-hook for iso-cvt.el."
  703.   (iso-fix-tex2iso)
  704.   (set-buffer-modified-p nil))
  705.  
  706. (defun iso-cvt-wfh ()
  707.   "write file hook for iso-cvt.el."
  708.   (iso-fix-iso2tex))
  709.  
  710. (defun iso-cvt-ash ()
  711.   "after save hook for iso-cvt.el."
  712.   (iso-fix-tex2iso)
  713.   (set-buffer-modified-p nil))
  714.  
  715. (add-hook 'find-file-hooks 'iso-cvt-ffh)
  716. (add-hook 'write-file-hooks 'iso-cvt-wfh)
  717. (add-hook 'after-save-hook 'iso-cvt-ash)
  718.  
  719. ;;; iso-cvt.el ends here
  720.